﻿using System;
using System.Linq;
using System.Collections.Generic;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil; 
using NTTDATA.BEENChina.ResultCertification.Config;
using System.ComponentModel;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil.CustomObject;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Text
{
    [Serializable]
    [VerfityAttribute(Id = "VerfityTX0301", Name = "各工程误录入检证", CategoryType = EnumCategoryType.文字列, Model = true)]  
    public class VerfityTx0301 : VerfityMulitResult
    {
        private CustomCollection<CheckPair> _checkList = new CustomCollection<CheckPair>();

        [Category("检查项目对照表"), Description("输入检查项目对照项目")]
        [TypeConverter(typeof(CustomCollectionConverter<CheckPair>))]
        [RefreshProperties(RefreshProperties.All)]
        public CustomCollection<CheckPair> CheckList
        {
            get { return _checkList; }
            //set { _checkList = value; }
        }

        public override bool CheckResult(List<List<string>> result1, string entryCommon1, List<List<string>> result2, string entryCommon2)
        {
            var resultA = result1.Select(t => t.Select(GetSpecialResult).ToList()).ToList () ;
            var resultB = result2.Select(t => t.Select(GetSpecialResult).ToList()).ToList();

            var verfity0301 = new Verfity0301(CheckList);
            
            verfity0301.SetChildImage(this.ChildImageObject);
            verfity0301.CompareRankX = this.CompareRankX;
            verfity0301.CompareRankY = this.CompareRankY;

            return verfity0301.CheckResult(resultA, entryCommon1, resultB, entryCommon2);
        }

        private string GetSpecialResult(string colResult)
        {
            var igronChar = new string[] { "？", "?"};

            return igronChar.Aggregate(colResult, (current, igron) => current.Replace(igron, "€"));
        } 
    }
}
